﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public class WxHelper
    {
        private static object _lock = new object();
        private static int count = 1;

        #region 生成编号
        /// <summary>
        /// 生成订单编号
        /// </summary>
        /// <returns></returns>
        public static string GetCode()
        {
            lock (_lock)
            {
                if (count >= 1000)
                {
                    count = 1;
                }
                var number = count.ToString("000");
                count++;
                return number;
            }
        }
        #endregion

        public static string GenerateOutTradeNo()
        {
            var ran = new Random();
            return string.Format("{0}{1:yyyyMMddHHmmss}{2}", WxConfig.MCHID, DateTime.Now, GetCode());
        }

    }
}
